import 'package:flutter/material.dart';

class EgAnimatedOpacity extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new Page();
  }
}

class Page extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return _PageState();
  }
}

class _PageState extends State<Page> {
  bool _visible = true;

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text("演示淡隐淡显的动画"),
      ),
      body: new Center(
        child: new AnimatedOpacity(
          opacity: _visible ? 1.0 : 0.0,
          duration: new Duration(milliseconds: 1000),
          child: new Container(
            width: 300,
            height: 300,
            color: Colors.lightGreen,
          ),
        ),
      ),
      floatingActionButton: new FloatingActionButton(
        onPressed: () {
          setState(() {
            _visible = !_visible;
          });
        },
        tooltip: "显示隐藏",
        child: new Icon(Icons.flip),
      ),
    );
  }
}
